<template>
  <div class="about">
    <v-header ref="header" />
    <v-sidebar ref="menu" />
    <div class="content-box" :class="{ 'content-collapse': collapse }">
      <v-tags></v-tags>
      <div class="content">
        <router-view v-slot="{ Component }">
          <transition name="move" mode="out-in">
            <component :is="Component" />
          </transition>
        </router-view>
        <!-- <el-backtop target=".content"></el-backtop> -->
      </div>
    </div>
  </div>
</template>
<script>
import vHeader from "../components/Header";
import vSidebar from "../components/Sidebar";
import vTags from "../components/Tags.vue";
import reqVue from "../utils/req.vue";
export default {
  components: {
    vHeader,
    vSidebar,
    vTags,
  },
  computed: {
    tagsList() {
      return this.$store.state.tagsList.map((item) => item.name);
    },
    collapse() {
      return this.$store.state.collapse;
    },
  },
  mounted() {
    this.init();
  },
  methods: {
    ///加载数据
    init() {
      let request = [
        {
          url: "doc/file/v1.0/photo/0",
          model: null,
        },
        {
          url: "business/emp/v1.0/currentuser",
          model: null,
        },
        {
          url: "business/menu/v1.0/menus",
          model: null,
        },
      ];
      reqVue.$All(request).then(
        function(res) {
          let photo = "";
          let employee = {};
          ///头像
          if (res[0].data.status) {
            if (res[0].data.body !== "") photo = res[0].data.body;
          } else {
            this.$message.error(res[0].data.message);
          }
          if (res[1].data.status) {
            if (res[1].data.body !== "") {
              employee = res[1].data.body;
              this.$store.commit("setCurrentUser", res[1].data.body);
            }
          } else {
            this.$message.error(res[1].data.message);
          }
          this.$nextTick(function() {
            this.$refs.header.initData(photo, employee);
          });
          if (res[2].data.status) {
            this.$nextTick(function() {
              this.$refs.menu.initMenu(res[2].data.body);
            });
          } else {
            this.$message.error(res[2].data.message);
          }
        }.bind(this)
      );
    },
  },
};
</script>
